#cmake file for dependencies 
#author:guyadong
#created:2018/05/10
cmake_minimum_required( VERSION 2.6 )
# 依赖代码位置
set(DEPENDENT_SOURCE_DIR "${PROJECT_BINARY_DIR}/dependent_sources" CACHE STRINGS "dependent source folder" FORCE)
#定义公共代码位置   
set( COMMONS_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/common_source_cpp)
if(NOT EXISTS ${COMMONS_SOURCE_DIR}/CMakeLists.txt )
	message( FATAL_ERROR "Not exists or Empty folder: ${COMMONS_SOURCE_DIR},the submodule must be init and pull" )	
endif()

if(WITH_STATIC_CRT)
	set(USE_THRIFT_MD_LIBRARY OFF PARENT_SCOPE)
else()
	set(USE_THRIFT_MD_LIBRARY ON PARENT_SCOPE)
endif()

if(NOT IS_DIRECTORY  "${CMAKE_CURRENT_LIST_DIR}/dist" )
message( FATAL_ERROR "Not exists or dist folder: ${CMAKE_CURRENT_LIST_DIR}/dist,need run 'tar xvf dist.tar.gz' to extract dist under the folder" )
endif()
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/dist" )
include (dist)

foreach( subdir common_source_cpp )
	if( IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/${subdir}" )
		MESSAGE( STATUS "Found sub project ${subdir}, adding it" )
		add_subdirectory( ${subdir} )
	endif()
endforeach()
